package com.example.demo.controller;
import com.example.demo.entity.Book_instrument;
import com.example.demo.entity.Instrument;
import com.example.demo.entity.User;
import com.example.demo.service.Book_instrumentService;
import com.example.demo.service.InstrumentService;
import com.example.demo.service.StudentService;
import com.example.demo.service.impl.StudentImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Controller
public class IndexController {

    @Autowired
    InstrumentService instrumentService;
    //重定向
    @GetMapping(value="index.html")
    public ModelAndView login(HttpSession session, Model model){
        ModelAndView modelAndView=new ModelAndView("index");
        List<Instrument> instrumentList= null;
        instrumentList = instrumentService.queryAllInstrument();
//        model.addAttribute("instruments",instrumentList);
        modelAndView.addObject("instruments",instrumentList);
//        model.addAttribute("user",session.getAttribute("loginuser"));
        return modelAndView;
    }
}
